/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tnviet.proj.jna.utilities;


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LayoutManager;
import java.awt.RenderingHints;
import javax.swing.JLabel;
import javax.swing.JPanel;



/**
 *
 * @author Administrator
 */


public class JNetAnalyzerLogo{

    public static JLabel getDropShadowLogo(String text,int tracking, float size, int style, Color color){
        
        
        JNetAnalyzerLogoLabel label= new JNetAnalyzerLogoLabel(text,tracking);
        label.setLeftShadow(1,1,Color.white);
	label.setRightShadow(1,1, Color.darkGray);
	label.setForeground(color);
        label.setFont(new Font("Verdana",style , ((int)size)));
        return label;
    }

    public static JLabel getOutLinedLogo(String text, int tracking, float size, int style, Color color){
        JNetAnalyzerLogoLabel label= new JNetAnalyzerLogoLabel(text,tracking);
        label.setLeftShadow(1,1,Color.gray);
	//label.setRightShadow(1,1, Color.white);
	label.setForeground(color);
        label.setFont(new Font("Lucida Sans",style , ((int)size)));
        return label;
    }

    public static JLabel get3DLogo(String text, int tracking, float size, int style,Color color){
        JNetAnalyzerLogoLabel label= new JNetAnalyzerLogoLabel(text,tracking);
        label.setLeftShadow(1,1,Color.white);
	label.setRightShadow(1,1, new Color(0xccccff));
	label.setForeground(color);
        label.setFont(new Font("Verdana",style , ((int)size)));        
        return label;
    }
}
class JNetAnalyzerLogoLabel extends JLabel{

    private int tracking;
    private int left_x,left_y,right_x, right_y;
    Color leftColor, rightColor;
    public JNetAnalyzerLogoLabel(String text, int tracking) {
        super(text);
        this.tracking = tracking;
    }

    public void setLeftShadow(int x, int y, Color color){
        left_x=x;
        left_y=y;
        leftColor=color;
    }
    public void setRightShadow(int x, int y, Color color){
        right_x=x;
        right_y=y;
        rightColor=color;
    }
    @Override
    public Dimension getPreferredSize() {
        String text = getText();
        FontMetrics fm = this.getFontMetrics(getFont());

        int w = fm.stringWidth(text);
        w += (text.length()-1)*tracking;
        w += left_x + right_x;
        int h = fm.getHeight();
        h += left_y + right_y;

        return new Dimension(w,h);
    }

    @Override
    public void paintComponent(Graphics g){        
        ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);;
        char[] chars = this.getText().toCharArray();
        FontMetrics fm = this.getFontMetrics(this.getFont());
        int h = fm.getAscent();
        int x = 0;
        for(int i=0; i<chars.length; i++) {
            char ch = chars[i];
            int w = fm.charWidth(ch) + tracking;

            g.setColor(leftColor);
            g.drawString(""+chars[i],x-left_x,h-left_y);

            g.setColor(rightColor);
            g.drawString(""+chars[i],x+right_x,h+right_y);

            g.setColor(getForeground());
            g.drawString(""+chars[i],x,h);

            x+=w;
	}
	((Graphics2D)g).setRenderingHint(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);

        }
    }

